package br.com.rodolfo.timesheet.dao;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import br.com.rodolfo.timesheet.entity.GenericBean;

public class GenericDAOImpl implements GenericDAO{
	@PersistenceContext
	protected EntityManager entityManager;
	
	public void create(GenericBean p) throws Exception {
		entityManager.persist(p);
	}


	
	public void update(GenericBean p) throws Exception {
		entityManager.merge(p);
		
	}
	
	
	public void delete(GenericBean p) throws Exception {
		p = entityManager.find(GenericBean.class, p.getId());
		entityManager.remove(p);
		
	}
	
	
	public void setEntityManager(EntityManager entityManager) {
		this.entityManager = entityManager;
	}


	
}
